<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>封条管理及验证系统--安全防护</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<%@ include file="/comm.jsp"%>
<style type="text/css">
	<!--
	fieldset {
	    padding:10px;
	    margin:10px;
	    width:270px;
	    color:#333; 
	} 
	legend {
	    color:#06c;
	    font-weight:800; 
	} 
		-->
	</style>
<script>
	var checkSeqFlag=true;
	var changeFlag=false;//判断是否有输入过内容
	
	function checkValid(txtValidate){
		changeFlag=true;
		
		var seqId=txtValidate.value;
		if(seqId==""){
			$d("seqIdError").innerHTML="请输入封条号码";
			return;
		}
		var params = {
				seqId:seqId
				};
		$.ajax({type: "POST",
		       url: "ajax_findValid.html",
		       data: params,
		       async: true,   
		       success: function(result){
				 var validate=result.validate;
				 if(validate != null){
				  	var status=validate.status;
				  	if(result.retcode == "0000"){//未激活
				  		seqIdError.innerHTML="";
				  		checkSeqFlag=true;
				  	}else{
				  		checkSeqFlag=false;
				  		seqIdError.innerHTML=result.retmsg;
				  	}
				 }else{
				 	seqIdError.innerHTML="封条不存在";
				 	checkSeqFlag=false;
				 }
			  }
			},"json");
	}
	
	function checkSubmit(){
		if(checkSeqFlag==false){
			alert("该封条不可用，请输入其他封条号码");
			return false;
		}
		return true;
	}
	
	//判断页面是否有做录入数据，如果有，则未保存的情况下页面离开要提示
	//onbeforeunload 目前三大主流浏览器中firefox和IE都支持onbeforeunload事件,opera尚未支持
	//window.onbeforeunload = function() {
	//	if(changeFlag==true){
    //		return "您有未保存的信息，您确定离开该页面吗？"; // return 这句必不可少
    //	}
	//}
	
	
</script>

<body leftmargin="0" topmargin="0" marginheight="0">
  <s:form name ="formpage" action="safetyInfo_add" namespace="/">
  	<s:token>
	</s:token>
	<div align="left">
  	<%@ include file="/messages.jsp"%>
			<table width="830px" border="0">
					<tr>
						<td colspan="2">
							<strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;安全防护</strong>
						</td>
					</tr>
					<tr>
						<td align="right" width="200">
							封条号码：
						</td>
						<td>
							<input name="seqId" type="text" maxlength="40"
								size="30" class="required"  title="*必填"
								onblur="checkValid(this);"
							/>
							<span id="seqIdError"></span>
						</td>
					</tr>
					<tr>
						<td align="right">
							设施名称：
						</td>
						<td>
							<input name="placeName" type="text" maxlength="40"
								size="30" class="required"  title="*必填"
							/>
						</td>
					</tr>
					<tr>
						<td align="right">
							设施编号：
						</td>
						<td>
							<input name="placeNo" type="text" maxlength="40"
								size="30" 
							/>
						</td>
					</tr>
					<tr>
						<td align="right" valign="top">
							备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注：
						</td>
						<td>
							<textarea name="remark" rows="6" cols="50"></textarea>
						</td>
					</tr>
					<tr>
						<td></td>
						<td>
							<br/>
							<input type="submit" class="button" id="ok" name="ok"
								value=" 确 定 " onclick="return checkSubmit();"/>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="button" class="button" id="btnBack" value=" 取 消 "
							onclick="return backHome(this.form,'safetyInfo_list.html');" />
						</td>
					</tr>
					</table>
			</div>
		</s:form>
  </body>
</html>